package com.jeesite.modules.codingrule.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;


/**
 * 编码规则Entity
 * @author 码脑洞
 * @version 2025-04-13
 */
@Table(name="t_coding_rule_lines", alias="a", label="编码规则信息", columns={
		@Column(name="auto_id", attrName="autoId", label="主键", isPK=true),
		@Column(name="header_id", attrName="headerId.autoId", label="编码规则头表ID"),
		@Column(name="seq", attrName="seq", label="序号"),
		@Column(name="coding_type", attrName="codingType", label="类型", comment="类型： 1. 流水号 2. 手工输入 3. 2位年 4. 2位月 5. 2位日"),
		@Column(name="coding_value", attrName="codingValue", label="设置值"),
		@Column(name="source_value", attrName="sourceValue", label="来源值"),
		@Column(name="length", attrName="length", label="长度", isUpdateForce=true),
		@Column(name="begin_value", attrName="beginValue", label="起始值"),
		@Column(name="separator", attrName="separator", label="分隔符"),
		@Column(includeEntity=DataEntity.class),
	}, orderBy="a.create_date ASC"
)
public class CodingRuleLines extends DataEntity<CodingRuleLines> {
	
	private static final long serialVersionUID = 1L;
	private Long autoId;		// 主键
	private CodingRuleHeader headerId;		// 编码规则头表ID 父类
	private Integer seq;		// 序号
	private String codingType;		// 类型： 1. 流水号 2. 手工输入 3. 2位年 4. 2位月 5. 2位日
	private String codingValue;		// 设置值
	private String sourceValue;		// 来源值
	private Integer length;		// 长度
	private String beginValue;		// 起始值
	private String separator;		// 分隔符

	public CodingRuleLines() {
		this(null);
	}

	public CodingRuleLines(CodingRuleHeader headerId){
		this.headerId = headerId;
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getAutoId() {
		return autoId;
	}

	public void setAutoId(Long autoId) {
		this.autoId = autoId;
	}
	
	public CodingRuleHeader getHeaderId() {
		return headerId;
	}

	public void setHeaderId(CodingRuleHeader headerId) {
		this.headerId = headerId;
	}
	
	// @NotNull(message="序号不能为空")
	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}
	
	@NotBlank(message="类型不能为空")
	@Size(min=0, max=10, message="类型长度不能超过 10 个字符")
	public String getCodingType() {
		return codingType;
	}

	public void setCodingType(String codingType) {
		this.codingType = codingType;
	}
	
	@Size(min=0, max=10, message="设置值长度不能超过 10 个字符")
	public String getCodingValue() {
		return codingValue;
	}

	public void setCodingValue(String codingValue) {
		this.codingValue = codingValue;
	}
	
	@Size(min=0, max=10, message="来源值长度不能超过 10 个字符")
	public String getSourceValue() {
		return sourceValue;
	}

	public void setSourceValue(String sourceValue) {
		this.sourceValue = sourceValue;
	}
	
	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}
	
	@Size(min=0, max=20, message="起始值长度不能超过 20 个字符")
	public String getBeginValue() {
		return beginValue;
	}

	public void setBeginValue(String beginValue) {
		this.beginValue = beginValue;
	}
	
	@Size(min=0, max=10, message="分隔符长度不能超过 10 个字符")
	public String getSeparator() {
		return separator;
	}

	public void setSeparator(String separator) {
		this.separator = separator;
	}
	
}